import { findComponentDownward } from '@/libs/util'

export default {
  methods: {

    updateRule (key, result, label) {
      let formModal = findComponentDownward(this, 'formModal')
      let $vm = formModal.formData

      let res = this[key] = result.data.map(item => {
        return {
          value: item.id,
          key: item.id,
          label: item[label]
        }
      })
      $vm.updateRule(key, {
        options: this[key]
      }, true)
      return res
    }
  }
}
